<?php
/** 
 * group_model
 * This class handles model work necessary for group Crud and List operations 
 * 
 * @author Ray Nowell
 *	
 */ 
class Group_model extends MY_Model {

	function Group_model()
	{
		parent::MY_Model();
	}
	
	function Add_group($data)
	{
		return $this->db->insert('group', $data);
	}
	
	function Update_group($data)
	{
		$this->db->where('group_id',element('group_id', $data));
		return $this->db->update('group',$data);
	}
	
	function Delete_group()
	{
		$ret_val = $this->delete_record('group','group_id');
		return $ret_val;	
	}
	/*
	 * Returns a list of current facilities
	 * @todo must filter by logged in user
	 */
	function get_group_list()
	{
		$select_fields =	"	 id
								,name
								,description";

		$this->db->select($select_fields, false);
		$this->db->from('groups');
		$query = $this->db->get();
		 
		return $query->result_array();
	}

	/*
	 * Returns a single group record based on group Id passed 
	 */
	function get_group_id_record($group_id)
	{
		 $query = $this->db->limit(1)->get_where('group', array('group_id' => $group_id));		 
		 return $query->row();
	}	
}
/* End of file group_model.php */
/* Location: ./system/application/models/group_model.php */